<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学生签到记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-signinstudent-edit" th:object="${course}">
            <input name="courseId" th:field="*{courseId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">课程名称：</label>
                <div class="col-sm-8">
                    <input name="courseName" th:field="*{courseName}"  class="form-control" type="text" disabled>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">校验码：</label>
                <div class="col-sm-8">
                    <input name="verifyCode" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-4"></div>
                <div class="col-sm-4">
                    <button id="buttonSignIn" onclick="signInButton()" class="btn btn-outline btn-large-dim btn-primary dim" type="button">
                        <i class="fa fa-check"></i>
                    </button>
                </div>
                <div class="col-sm-4"></div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "cws/signinstudent";
        // $("#form-signinstudent-edit").validate({
        //     focusCleanup: true
        // });

        // function submitHandler() {
        //     if ($.validate.form()) {
        //         $.operate.save(prefix + "/edit", $('#form-signinstudent-edit').serialize());
        //     }
        // }
        function signInButton(){
            if ($.validate.form()) {
                $.ajax({
                    type: "post",
                    url: prefix + "/add",
                    data: {"courseId": $('input[name="courseId"]').val(), "verifyCode": $('input[name="verifyCode"]').val()},
                    dataType: 'json',
                    success: function (result) {
                        $.modal.alertSuccess(result.msg);
                        $.table.refresh();
                    },
                    error: function (result) {
                        $.modal.alertWarning(result.msg);
                    }
                })
            }
        }
    </script>
</body>
</html>